using System;
using System.Data;

using SqlHelperForCry.Common;

namespace Torch.WL.Entity
{
    [Table("Tb_Sys_UserGroup", "UG_ID", "Torch.WL.ConnectionString")]
	public class Tb_Sys_UserGroup : Info
	{
		#region SQL column name consts 
		public const string SQLCOL_UG_ID = "UG_ID";
		public const string SQLCOL_UG_NAME = "UG_Name";
		public const string SQLCOL_UG_ORDER = "UG_Order";
		public const string SQLCOL_UG_DESCRIPTION = "UG_Description";
		public const string SQLCOL_UG_DEPTH = "UG_Depth";
		public const string SQLCOL_UG_SUPERIORID = "UG_SuperiorID";
		public const string SQLCOL_UG_COUNT = "UG_Count";
		#endregion


		#region Contructors
		/// <summary>
		/// Construct empty entity
		/// </summary>
		public Tb_Sys_UserGroup () {}

		/// <summary>
		/// Construct entity by primary key, other fields will be assigned by 
		/// "Load" method.
		/// </summary>
		public Tb_Sys_UserGroup (int UG_ID)
		{
			this.UG_ID = UG_ID;
		}
		#endregion

		public override void Init (DataRow row)
		{
			UG_ID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_UG_ID]);
			UG_Name = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_UG_NAME]);
			UG_Order = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_UG_ORDER]);
			UG_Description = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_UG_DESCRIPTION]);
			UG_Depth = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_UG_DEPTH]);
			UG_SuperiorID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_UG_SUPERIORID]);
			UG_Count = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_UG_COUNT]);
		}

		#region Properties 
		#region Property <int> UG_ID
		[Property("UG_ID", 4, SqlDbType.Int, true, true)]
		public int UG_ID 
		{
			get { return _UG_ID; }
			set { _UG_ID = value; }
		}
		private int _UG_ID = int.MinValue;
		#endregion

		#region Property <string> UG_Name
		[Property("UG_Name", 60, SqlDbType.NVarChar, false, false)]
		public string UG_Name 
		{
			get { return _UG_Name; }
			set { _UG_Name = value; }
		}
		private string _UG_Name = null;
		#endregion

		#region Property <int> UG_Order
		[Property("UG_Order", 4, SqlDbType.Int, false, false)]
		public int UG_Order 
		{
			get { return _UG_Order; }
			set { _UG_Order = value; }
		}
		private int _UG_Order = int.MinValue;
		#endregion

		#region Property <string> UG_Description
		[Property("UG_Description", 100, SqlDbType.NVarChar, false, false)]
		public string UG_Description 
		{
			get { return _UG_Description; }
			set { _UG_Description = value; }
		}
		private string _UG_Description = null;
		#endregion

		#region Property <int> UG_Depth
		[Property("UG_Depth", 4, SqlDbType.Int, false, false)]
		public int UG_Depth 
		{
			get { return _UG_Depth; }
			set { _UG_Depth = value; }
		}
		private int _UG_Depth = int.MinValue;
		#endregion

		#region Property <int> UG_SuperiorID
		[Property("UG_SuperiorID", 4, SqlDbType.Int, false, false)]
		public int UG_SuperiorID 
		{
			get { return _UG_SuperiorID; }
			set { _UG_SuperiorID = value; }
		}
		private int _UG_SuperiorID = int.MinValue;
		#endregion

		#region Property <int> UG_Count
		[Property("UG_Count", 4, SqlDbType.Int, false, false)]
		public int UG_Count 
		{
			get { return _UG_Count; }
			set { _UG_Count = value; }
		}
		private int _UG_Count = int.MinValue;
		#endregion
		#endregion


		public bool LoadByIdentity(int UG_ID)
		{
			return DataAccess.SelectByIdentity(this, Convert.ToInt64(UG_ID));
		}


		public bool DeleteByIdentity()
		{
			return DataAccess.DeleteByIdentity(this);
		}
	}
}
